import type { ServerConfig } from '../types/service'

// 完整的服务器配置数据
export const servers: ServerConfig[] = [
  {
    id: 'e3-1240v3-16gb-4x240gb',
    name: 'E3-1240 v3, 16GB RAM, 4×240GB SSD',
    cpu: {
      model: 'Intel Xeon E3-1240 v3',
      cores: 4,
      threads: 8,
      baseFreq: '3.40 GHz',
      turboFreq: '3.80 GHz',
    },
    ram: {
      size: '16GB',
      type: 'Hynix DDR3-1600 ECC',
    },
    storage: {
      total: '960GB',
      details: '4×240GB Crucial M500 SSD',
    },
    network: {
      bandwidth: '1Gbps',
      transfer: '100TB',
    },
    ip: {
      count: 1,
      available: 1,
      subnet: '/30',
    },
    price: 159,
    category: 'entry',
    features: ['企业级SSD', 'ECC内存', '美国数据中心'],
  },
  {
    id: 'e3-1240v3-32gb-1.92tb',
    name: 'E3-1240 v3, 32GB RAM, 1.92TB SSD',
    cpu: {
      model: 'Intel Xeon E3-1240 v3',
      cores: 4,
      threads: 8,
      baseFreq: '3.40 GHz',
      turboFreq: '3.80 GHz',
    },
    ram: {
      size: '32GB',
      type: 'Hynix DDR3 ECC',
    },
    storage: {
      total: '1.92TB',
      details: '1.92TB Samsung PM863A SSD',
    },
    network: {
      bandwidth: '1Gbps',
      transfer: '100TB',
    },
    ip: {
      count: 1,
      available: 1,
      subnet: '/31',
    },
    price: 179,
    category: 'entry',
    features: ['大容量SSD', 'ECC内存', '美国数据中心'],
  },
  {
    id: 'd-1541-64gb-2tb-nvme-10g',
    name: 'D-1541, 64GB RAM, 4TB HDD @ 10Gbps',
    cpu: {
      model: 'Intel Xeon D-1541',
      cores: 8,
      threads: 16,
      baseFreq: '2.10 GHz',
      turboFreq: '2.70 GHz',
    },
    ram: {
      size: '64GB',
      type: 'DDR4-2133 ECC',
    },
    storage: {
      total: '480GB SSD + 4TB HDD',
      details: '480GB Samsung 990 PRO NVMe SSD+4TB HDD',
    },
    network: {
      bandwidth: '10Gbps',
      transfer: '100TB',
    },
    ip: {
      count: 2,
      available: 1,
    },
    price: 259,
    category: 'advanced',
    features: ['10Gbps带宽', 'NVMe高速存储', 'DDR4内存'],
  },
  {
    id: 'dual-gold-5218-128gb-2x1tb-nvme',
    name: 'Dual Intel Xeon E5-2640 v2, 192GB RAM, 1TB SSD',
    cpu: {
      model: 'Intel Xeon E5-2640 v2',
      cores: 16,
      threads: 32,
      baseFreq: '2.00 GHz',
      turboFreq: '2.50 GHz',
    },
    ram: {
      size: '192GB',
      type: 'DDR3-1600 ECC',
    },
    storage: {
      total: '1TB',
      details: '1TB Samsung 980 PRO NVMe',
    },
    network: {
      bandwidth: '10Gbps',
      transfer: '100TB',
    },
    ip: {
      count: 5,
      available: 1,
      subnet: '/29',
    },
    price: 359,
    category: 'advanced',
    features: ['32核心64线程', '10Gbps带宽', 'NVMe存储', '高主频'],
  },

]

// 获取推荐的服务器（首页展示）
export const getFeaturedServers = (): ServerConfig[] => {
  return [
    servers[1], // E3-1240 v3, 32GB - 入门级
    servers[2], // D-1541 @ 10Gbps - 标准级
    servers[3], // Dual Gold 5218 - 高级
    servers[5], // Dual EPYC 7542 - 企业级
  ]
}

// 获取热门服务器（多个配置）
export const getPopularServers = (): ServerConfig[] => {
  return servers.slice(0, 6) // 返回前6个配置
}

// 获取所有服务器
export const getAllServers = (): ServerConfig[] => {
  return servers
}

// 根据分类筛选
export const getServersByCategory = (category: ServerConfig['category']): ServerConfig[] => {
  return servers.filter(server => server.category === category)
}

// 根据ID获取
export const getServerById = (id: string): ServerConfig | undefined => {
  return servers.find(server => server.id === id)
}

// 根据价格范围筛选
export const getServersByPriceRange = (min: number, max: number): ServerConfig[] => {
  return servers.filter(server => server.price && server.price >= min && server.price <= max)
}

